home *** CD-ROM | disk | FTP | other *** search
/ Champak 106 / Vol 106.iso / games / rain_for.swf / scripts / __Packages / Germ.as < prev    next >
Encoding:
Text File  |  2010-04-12  |  2.8 KB  |  116 lines

  1. class Germ extends smashing.Renderable
  2. {
  3.    var update;
  4.    var x;
  5.    var y;
  6.    var handler;
  7.    var nSegment;
  8.    var oData;
  9.    var mcBuild;
  10.    var sCrit;
  11.    var a;
  12.    var r = 15;
  13.    var grabbable = true;
  14.    var lowerLimit = 1.5;
  15.    var variation = 1.5;
  16.    var cNoise = 0;
  17.    var initThrust = 300;
  18.    var mx = 400;
  19.    var my = 0;
  20.    var bGot = false;
  21.    function Germ()
  22.    {
  23.       super();
  24.       this.update = this.updateRest;
  25.       this.render = this.renderRest;
  26.    }
  27.    function updateRest(nElapsed)
  28.    {
  29.    }
  30.    function updateRun(nElapsed)
  31.    {
  32.       this.my += smashing.Phys.gr * nElapsed;
  33.       this.x += this.mx * nElapsed;
  34.       this.y += this.my * nElapsed;
  35.    }
  36.    function updateFly(nElapsed)
  37.    {
  38.       this.x += this.mx * nElapsed;
  39.    }
  40.    function updateHide(nElapsed)
  41.    {
  42.    }
  43.    function renderRest()
  44.    {
  45.       var _loc2_ = smashing.Viewport.getPos(this);
  46.       this._x = _loc2_.x + smashing.Viewport.centerX;
  47.       this._y = _loc2_.y + smashing.Viewport.centerY;
  48.    }
  49.    function renderRun()
  50.    {
  51.       var _loc2_ = smashing.Viewport.getPos(this);
  52.       this._x = _loc2_.x + smashing.Viewport.centerX;
  53.       this._y = _loc2_.y + smashing.Viewport.centerY;
  54.       if(Math.abs(_loc2_.x) > smashing.Viewport.centerX + this._width)
  55.       {
  56.          this.handler.removeClip(this);
  57.       }
  58.       else if(Math.abs(_loc2_.y) > smashing.Viewport.centerY + this._height)
  59.       {
  60.          this.handler.removeClip(this);
  61.       }
  62.    }
  63.    function react(oPlayer)
  64.    {
  65.       if(this.bGot == false)
  66.       {
  67.          switch(this.nSegment)
  68.          {
  69.             case 0:
  70.                this.oData.sCritBot = null;
  71.                break;
  72.             case 1:
  73.                this.oData.sCritMid = null;
  74.                break;
  75.             case 2:
  76.                this.oData.sCritTop = null;
  77.          }
  78.          this.bGot = true;
  79.          delete this.mcBuild.mcGerm;
  80.          oPlayer.getGerm(this);
  81.          this.my = - this.initThrust;
  82.          switch(this.sCrit)
  83.          {
  84.             case "butterfly":
  85.             case "macaw":
  86.                this.update = this.updateFly;
  87.                break;
  88.             case "sloth":
  89.                this.update = this.updateHide;
  90.                break;
  91.             default:
  92.                this.update = this.updateRun;
  93.          }
  94.          this.render = this.renderRun;
  95.          this.a.gotoAndStop("away");
  96.          this.a.a.stop();
  97.       }
  98.    }
  99.    function checkHit(oPlayer)
  100.    {
  101.       var _loc2_ = new smashing.Point(oPlayer.x - this.x,oPlayer.y - this.y);
  102.       var _loc3_ = this.r + oPlayer.r;
  103.       if(_loc2_.dot(_loc2_) < _loc3_ * _loc3_)
  104.       {
  105.          return true;
  106.       }
  107.       return false;
  108.    }
  109.    function setCritter(cr)
  110.    {
  111.       this.gotoAndStop(cr);
  112.       this.sCrit = cr;
  113.       _global.mcRoot.mcMenu.setFlash(cr);
  114.    }
  115. }
  116.